package com.peak.distribution.entity.goods;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.google.common.collect.Lists;
import com.peak.distribution.enums.Constants;
import com.peak.spring.boot.api.entity.DefaultStategyEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 商品组
 * @author peak
 *
 */
@Entity
@Table(name = "dis_goods_group")
@Data
@EqualsAndHashCode(callSuper=true)
public class DisGoodsGroup extends DefaultStategyEntity {

	private static final long serialVersionUID = Constants.DISTRIBUTION_VERSION;
	
	/** 商品列表 */
	private List<DisGoods> goodses = Lists.newArrayList();

	@OneToMany(mappedBy = "group")
	@Fetch(FetchMode.SELECT)
	@LazyCollection(LazyCollectionOption.TRUE)
	public List<DisGoods> getGoodses() {
		return goodses;
	}
}
